<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\admin\model\Sysarticle;
use app\admin\model\Affair;
use app\admin\model\Yongtu;
use app\admin\model\Gtypes;
use app\admin\model\Yaosu;
use app\admin\model\Lqway;

use think\Config;
/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     * @ApiMethod (GET)
     */
    public function index()
    {
        $this->success('请求成功');
    }
	/**
     * 用户须知
     *
     * @ApiMethod (GET)
     */
	public function getxz(){
		$data=Sysarticle::find(2);
		 $this->success('请求成功',$data);
	}
	/**
     * 用户指南
     *
     * @ApiMethod (GET)
     */
	public function getzn(){
		$data=Sysarticle::find(3);
		 $this->success('请求成功',$data);
	}
	/**
     * 获取公证事项
     *
     * @ApiMethod (POST)
     * @param int $did 公证用途id
     */
	public function getshixiang(){
		$did=$this->request->post('did');
		$data=Affair::where("FIND_IN_SET({$did},yongtu_ids)")->select();
		$this->success('请求成功',$data);
	}
	/**
     * 获取公证用途
     *
     * @ApiMethod (GET)
     */
	public function getyongtu(){
		$data=Yongtu::select();
		$this->success('请求成功',$data);
	}
	/**
     * 获取公证用途详情
     *
     * @ApiMethod (GET)
     * @param int $yid 公证用途id
     */
	public function ytdetail(){
		$yid=input('yid');
		$data=Yongtu::find($yid);
		$this->success('请求成功',$data);
	}
	/**
     * 获取公证事项详情
     *
     * @ApiMethod (GET)
     * @param int $sid 公证事项id
     */
	public function sxdetail(){
		$sid=input('sid');
		$data=Affair::find($sid);
		$this->success('请求成功',$data);
	}
	/**
     * 获取公证类型
     *
     * @ApiMethod (GET)
     */
	public function gtypes(){
		$data=Gtypes::field('id,name')->select();
		$data[]=array('id'=>0,'name'=>'请选择','disabled'=>true);
		$ids = array_column($data, 'id');
		array_multisort($ids, SORT_ASC, $data);
		$this->success('请求成功',$data);
	}
	/**
     * 获取要素信息列表
     *
     * @ApiMethod (GET)
     * @param int $sid 公证事项id
     */
	public function getyslist(){
		$sid=input('sid');
		$list=Yaosu::where('affair_id',$sid)->select();
		$this->success('请求成功',$list);
	}
	/**
     * 获取领取方式
     *
     * @ApiMethod (GET)
     */
	public function getlqway(){
		$lqway=Lqway::select();
		$this->success('请求成功',$lqway);
	}
	
	/**
     * 获取自取信息
     *
     * @ApiMethod (GET)
     */
	public function getziqu(){
		$ziqu=config('site')['ziqu'];
		$this->success('请求成功',$ziqu);
	}
	/**
     * 获取要素信息详情
     *
     * @ApiMethod (GET)
     * @param int $yid 要素信息id
     */
	public function getyaosu(){
		$yid=input('yid');
		$data=Yaosu::find($yid);
		$data['adjson']	=json_decode($data['adjson'],true);
		$this->success('请求成功',$data);
	}
}
